]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
network: ignore unrecognized/irrelevant devices/connections
authorDan Winship <danw@gnome.org>
Tue, 21 Aug 2012 14:55:40 +0000 (10:55 -0400)
committerDan Winship <danw@gnome.org>
Tue, 21 Aug 2012 17:37:54 +0000 (13:37 -0400)
Don't log a warning if an unrecognized device type is seen.

Don't show slave connections in the menu. (Eg, don't show the
individual wired connections making up a bond, since they can't be
used individually.)

Make the icon only reflect the status of connections that are visible
in the menu. (ie, don't show the "connecting" icon when an
unrecognized connection type is connecting, and don't show a
"connected" status if the only active connections are of unrecognized
types.)

https://bugzilla.gnome.org/show_bug.cgi?id=682364

js/ui/status/network.js

index 82dbbcf5578607f6e9f0e1a12588ee71571f656a..cb1991c8deeb2aecea2b9133730b6b9ba6369724 100644 (file)
@@ -1832,8 +1832,7 @@ const NMApplet = new Lang.Class({
             devices.push(wrapper);
 
             this._syncSectionTitle(wrapper.category);
-        } else
-            log('Invalid network device type, is ' + device.get_device_type());
+        }
     },
 
     _deviceRemoved: function(client, device) {
@@ -1852,9 +1851,32 @@ const NMApplet = new Lang.Class({
         this._syncSectionTitle(wrapper.category)
     },
 
+    _getSupportedActiveConnections: function() {
+        let activeConnections = this._client.get_active_connections() || [ ];
+        let supportedConnections = [];
+
+        for (let i = 0; i < activeConnections.length; i++) {
+            let devices = activeConnections[i].get_devices();
+            if (!devices || !devices[0])
+                continue;
+            // Ignore connections via unrecognized device types
+            if (!this._dtypes[devices[0].device_type])
+                continue;
+
+            // Ignore slave connections
+            let connectionPath = activeConnections[i].connection;
+            let connection = this._settings.get_connection_by_path(connectionPath)
+            if (this._ignoreConnection(connection))
+                continue;
+
+            supportedConnections.push(activeConnections[i]);
+        }
+        return supportedConnections;
+    },
+
     _syncActiveConnections: function() {
         let closedConnections = [ ];
-        let newActiveConnections = this._client.get_active_connections() || [ ];
+        let newActiveConnections = this._getSupportedActiveConnections();
         for (let i = 0; i < this._activeConnections.length; i++) {
             let a = this._activeConnections[i];
             if (newActiveConnections.indexOf(a) == -1) // connection is removed
@@ -1958,10 +1980,24 @@ const NMApplet = new Lang.Class({
         this._updateIcon();
     },
 
+    _ignoreConnection: function(connection) {
+        let setting = connection.get_setting_connection();
+        if (!setting)
+            return true;
+
+        // Ignore slave connections
+        if (setting.get_master())
+            return true;
+
+        return false;
+    },
+
     _readConnections: function() {
         let connections = this._settings.list_connections();
         for (let i = 0; i < connections.length; i++) {
             let connection = connections[i];
+            if (this._ignoreConnection(connection))
+                continue;
             if (connection._updatedId) {
                 // connection was already seen (for example because NetworkManager was restarted)
                 continue;
@@ -1975,6 +2011,8 @@ const NMApplet = new Lang.Class({
     },
 
     _newConnection: function(settings, connection) {
+        if (this._ignoreConnection(connection))
+            return;
         if (connection._updatedId) {
             // connection was already seen
             return;